<HTML><HEAD><TITLE>get_var_info(?Var, ?InfoName, -Value)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Type Testing</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>get_var_info(?Var, ?InfoName, -Value)</H1>
Succeeds if Var is an uninstantiated variable, InfoName is a valid
information name and the information value Value unifies with the value of
the information.


<DL>
<DT><EM>Var</EM></DT>
<DD>Prolog Term, usually a variable.
</DD>
<DT><EM>InfoName</EM></DT>
<DD>Atom or variable.
</DD>
<DT><EM>Value</EM></DT>
<DD>Atom or variable.
</DD>
</DL>
<H2>Description</H2>
   This predicate is used to test the type of a free variable or to get its
   source name (when available).

<P>
   The possible values for InfoName are type or name.

<P>
   If InfoName unifies with name, the predicate will succeed if the source
   name of the free variable Var is available and unifies with Value.

<P>
   If InfoName unifies with type, the predicate will succeed if Value
   unifies with the type of the variable Var.

<P>
   The possible types are:

<P>
<PRE>
    meta      an attributed variable (metaterm)
    free      a free variable
</PRE>

<H3>Modes and Determinism</H3><UL>
<LI>get_var_info(?, +, -) is semidet
<LI>get_var_info(?, -, -) is semidet
</UL>
<H3>Fail Conditions</H3>
Fails if Var is not a variable
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>InfoName or Value is neither an atom nor a variable.
<DT><EM>(6) out of range </EM>
<DD>InfoName is not an information name.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      ?- suspend:(Var1 &gt; Var2), get_var_info(Var1, Info, Value).
      Var2 = Var2
      Var1 = Var1
      Info = name
      Value = 'Var1'
      Delayed goals:
       Var1 &gt; Var2     More? (;)

      Var2 = Var2
      Var1 = Var1
      Info = type
      Value = meta

      Delayed goals:
       Var1 &gt; Var2
      yes.

      ?- get_var_info(Var1, type, Type).
      Var1 = Var1
      Type = free
      yes.

      ?- set_flag(variable_names,off).
      yes.

      ?- get_var_info(Var1, name, Name).
      no (more) solution.

Fail:
      get_var_info(atom, name, Name).
      set_flag(variable_names, off),
          get_var_info(X, name, Name).

Error:
      get_var_info(X, not_an_info, Y).    (Error 6)
      get_var_info(X, type, 123).         (Error 5)




</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/env/set_flag-2.html">set_flag / 2</A>, <A HREF="../../kernel/typetest/type_of-2.html">type_of / 2</A>, <A HREF="../../kernel/typetest/var-1.html">var / 1</A>
</BODY></HTML>
